package com.base.myproject.client.ui;

import com.base.myproject.client.init.StartUp;
import com.extjs.gxt.ui.client.Style.Orientation;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.layout.RowData;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import com.google.gwt.event.logical.shared.ResizeEvent;
import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.user.client.Window;
 
public class Main {

	public ContentPanel initWeiget() {


//		StartUp s = new StartUp();
//		s.start();
		

		
		final ContentPanel panel = BaseMainPanel.getInstance();

		panel.setLayout(new RowLayout(Orientation.VERTICAL));

		panel.setMonitorWindowResize(true);
	//	panel.setAnimCollapse(true);

		
		if(panel.isRendered())
			panel.setFrame(false);
		panel.setHeaderVisible(false);
		panel.setTopComponent(BaseMenuBar.getinstance());

		//panel.add(BaseMenuBar.getinstance(), new RowData(1, -1, new Margins(4)));
		panel.add( BaseToolBar.getInstance(), new RowData(1, -1, new Margins(0)));
		panel.add( BaseTabPanel.getInstance(), new RowData(1, 1, new Margins(0,0,0,0)));
		panel.setBottomComponent(BaseStatus.getInstance());
		
		
		StartUp startup =new StartUp();
		startup.start();
	//	panel.setBodyStyleName("backgroupimage");
	//	Loading.getinstance().loaded();
		//-----------------------------------b

		
		


////////
//		  Contract contract = new Contract();
//		  contract.setBusino("1001");
//		  contract.complete();
//		  BaseTabPanel.getInstance().addTab("合同",contract);
//		  
		  //********//
	
//
		  
		  //---------------------------------e
		panel.setBottomComponent(BaseStatus.getInstance());
		ResizeHandler resizehandler = new  ResizeHandler(){
			public void onResize(ResizeEvent event)
			 {
				
				// panel.setHeight(Window.getClientHeight()-10);
				// panel.setAutoHeight(true);
				// panel.setm

				 panel.setWidth(Window.getClientWidth());
				// panel.setAnimCollapse(true);
				// if(panel.getHeight()<Window.getClientHeight())

					 panel.setHeight(Window.getClientHeight());
				 BaseTabPanel.getInstance().setHeight(Window.getClientHeight()-85); //-85  
				 BaseTabPanel.getInstance().setWidth(Window.getClientWidth());  

			 }
		};
		//panel.setScrollMode(Scroll.AUTO);
		//----------
		
		Window.addResizeHandler(resizehandler);
		//panel.setHeight("900px");
		//----------
		panel.setHeight(Window.getClientHeight()-22);
		panel.setWidth(Window.getClientWidth());
		BaseTabPanel.getInstance().setHeight(Window.getClientHeight()-85);
		
		return panel;
	}
	
	public static void main(String[] argv)
	{
		
		
		String[][] array = new String[][]{{"1001","30","10"},
				{"1002","40","30"},
				{"1003","50","40"},{"1004","50","40"},{"1005","60","50"}};
		Main m = new Main();
		

		Object[] main =new  Object[]{m.new ratifyobject("1001"),m.new ratifyobject("1002"),m.new ratifyobject("1003"),m.new ratifyobject("1004"),m.new ratifyobject("1005")};
		for(int i=0;i<array.length;i++)
		{
			
			for(int j=0;j<5;j++)
			{
				if(array[i][1].equals(array[j][2]))
				{
					((ratifyobject)main[i]).add((ratifyobject)main[j]);
					System.out.println("bingo!!"+((ratifyobject)main[i]).name + " + "+((ratifyobject)main[j]).name);
				}
			}
		}
			System.out.println(((ratifyobject)main[1]).ll.size());
			((ratifyobject)main[0]).path = "1001";
			m.listratifyobj((ratifyobject)main[0]);
			
			System.out.println(Strlink.get(0));
			System.out.println(Strlink.get(1));
	}
	static public java.util.LinkedList<String > Strlink = new java.util.LinkedList<String>();
	static String str="";
	public void listratifyobj(ratifyobject ro)
	{
		System.out.println(ro.ll.size());
		if(ro.ll.size()>0)
		{
			for(int i=0;i<ro.ll.size();i++)
			{
				
					((ratifyobject)ro.ll.get(i)).path = ro.path;
					((ratifyobject)ro.ll.get(i)).path +="->"+((ratifyobject)ro.ll.get(i)).name;
				
				
				listratifyobj((ratifyobject)ro.ll.get(i));
				
			}
		}
		else
		{
			
			Strlink.add(ro.path);
		}
	//System.out.println(ro.name+"--"+ro.path);
		
	}

	
	public class ratifyobject
	{
		public java.util.LinkedList<ratifyobject> ll = new java.util.LinkedList<ratifyobject>();
	
		public String name = null;
		public String path = "";
		public ratifyobject()
		{
			
		}
		public ratifyobject(String name)
		{
			this.name = name;
		}
		public void setName(String name)
		{
			this.name = name;
			
		}
		public void add(ratifyobject ro)
		{
			ll.add(ro);
		}
		
	}
	
	
}
